<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- var element = document.querySelector(selectors);

    <div class="box">abc</div>
    <div id="id">def</div>
    <h3><span><input type="text"></span></h3>
    <script>
        var elem1 = document.querySelector('.box');
        console.log(elem1);
        var elem2 = document.querySelector('#id');
        console.log(elem2);
        var elem3 = document.querySelector('h3 span input');
        console.log(elem3);
    </script>

    <div class="box">abc</div>
    <div id="id">def</div>
    <script>
        var elems = document.querySelectorAll('div');
        console.log(elems);
    </script> -->

    <!-- <button id="btn">点我一下</button>
    <script>
        var btn = document.getElementById('btn');
        btn.onclick = function() {
            alert("hello world");
        }
    </script> -->

    <!--  读操作 -->
    <!-- var renderedText = HTMLElement.innerText; -->
    <!-- 写操作 -->
    <!-- HTMLElement.innerText = string; --> 

    <!-- <div>
        <span>hello world</span>
        <span>hello world</span>
    </div>
    <script>
        var div = document.querySelector('div');
        //读取div内部内容
        console.log(div.innerText);
        //修改div内部北荣，界面上就会同步修改
        div.innerText = 'hello js <span>hello js</span>';
    </script> -->
    
    <!--  读操作 -->
    <!-- var content = element.innerHTML; -->
    <!-- 写操作 -->
    <!-- element.innerHTML = htmlstring;  -->

    <!-- <div>
        <span>hello world</span>
        <span>hello world</span>
    </div>
    <script>
        var div = document.querySelector('div');
        //读取页面内容
        console.log(div.innerHTML);
        //修改页面内容
        div.innerHTML = '<span>hello js</span>';
    </script> -->

    <!-- <img src="flower.png" alt="花花" title="白色的花">
    <script>
        var img = document.querySelector('img');
        console.dir(img);
    </script> -->

    <!-- <img src="flower.png" alt="花花" title="白色的花">
    <script>
        var img = document.querySelector('img');
        console.log(img.src);
        console.log(img.title);
        console.log(img.alt);
    </script> -->

    <!-- <img src="flower.png" alt="花花" title="白色的花">
    <script>
        var img = document.querySelector('img');
        img.onclick = function() {
            if (img.src.lastIndexOf('flower.png') !== -1) {
                img.src = './red.png';
            } else {
                img.src = './flower.png';
            }
        }
    </script> -->

    <!-- <input type="button" value="播放">
    <script>
        var btn = document.querySelector('input');
        btn.onclick = function() {
            if (btn.value === '播放') {
                btn.value = '暂停';
            } else {
                btn.value = '播放';
            }
        }
    </script> -->

    <!-- <input type="text" id="text" value="0">
    <input type="button" id="btn" value="点我+1">

    <script>
        var text = document.querySelector('#text');
        var btn = document.querySelector('#btn');

        btn.onclick = function() {
            var num = +text.value;
            console.log(num);
            num++;
            text.value = num;
        }
    </script> -->

    <!-- <input type="checkbox" id="all">我全都要<br>
    <input type="checkbox" class="eat">炸鸡<br>
    <input type="checkbox" class="eat">椒麻鸡<br>
    <input type="checkbox" class="eat">烤鸡<br>
    <input type="checkbox" class="eat">窑鸡<br>
    <input type="checkbox" class="eat">卤鸡<br>
    <input type="checkbox" class="eat">盐焗鸡<br>
    <input type="checkbox" class="eat">手撕鸡<br>
    <input type="checkbox" class="eat">椰子鸡<br>

    <script>
        //1. 获取到元素
        var all = document.querySelector('#all');
        var eats = document.querySelectorAll('.eat');
        //2. 给all注册点击事件，选中/取消所有选项
        all.onclick = function() {
            for (var i = 0; i < eats.length; i++) {
                eats[i].checked = all.checked;
            }
        }
        //3. 给eat注册点击事件
        for (var i = 0; i < eats.length; i++) {
            eats[i].onclick = function() {
                //检测当前是不是所有的girl都被选中了
                all.checked = checkedEat(eat);
            }
        }
        //4. 实现 checkEat
        function checkEat(eat) {
            for (var i = 0; i < eaats.length; i++) {
                if (!eats[i].checked) {
                    //只要一个girl没被选中，就认为结果是false(找到了反响)
                    return false;
                }
            }
            return true;
        }
    </script> -->

    <!-- <div style="font-size: 20px; font-weight: 700;">
        哈哈
    </div>
    <script>
        var div = document.querySelector('div');
        div.onclick = function() {
            var curFontSize = parseInt(this.style.fontSize);
            curFontSize += 10;
            this.style.fontSize = curFontSize + "px";
        }
    </script> -->

    <!-- <div class="container light">
        这是一大段话. <br>
        这是一大段话. <br>
        这是一大段话. <br>
        这是一大段话. <br>
    </div>

    <style>
        * {
        margin: 0;
        padding: 0;
    }

    html, body {
        width: 100%;
        height: 100%;
    }

    .container {
        width: 100%;
        height: 100%;
    }

    .light {
        background-color: #f3f3f3;
        color: #333;
    }

    .dark {
        background-color: #333;
        color: #f3f3f3;
    }
    </style>

    <script>
        var div = document.querySelector('div');
        div.onclick = function() {
            console.log(div.className);
            if (div.className.indexOf('light') != -1) {
                div.className = 'container dark';
            } else {
                div.className = 'container light';
            }
        }
    </script> -->

    <!-- <script>
        var element = document.createElement(tagName[, options]);
    </script> -->

    <!-- <div class="container"> </div>

    <script>
        var div = document.createElement('div');
        div.id = 'mydiv';
        div.className = 'box';
        div.innerHTML = 'hehe';
        console.log(div);

        var container = document.querySelector('.container');
        container.appendChild(div);
    </script> -->

    <!-- <div class="container">
        <div>11</div>
        <div>12</div>
        <div>13</div>
        <div>14</div>
    </div>

    <script>
        var newDiv = document.createElement('div');
        newDiv.innerHTML = '我是新节点';

        var container = document.querySelector('.container');
        console.log(container.children);
        container.insertBefore(newDiv, container.children[1]);
        container.insertBefore(newDiv, container.children[0]);
    </script> -->

    <!-- <div class="container">
        <div>11</div>
        <div>12</div>
        <div>13</div>
        <div>14</div>
    </div>

    <script>
        var newDiv = document.createElement('div');
        newDiv.innerHTML = '我是新节点';

        var container = document.querySelector('.container');
        console.log(container.children);
        container.insertBefore(newDiv, container.children[1]);

        newDiv.innerHTML = '我的修改过的新节点';
    </script> -->

</body>
</html>